<template>
<a-modal
      title="评阅信息"
      :visible="editVisible"
      :confirmLoading="confirmLoading"
      @ok="handleSave"
      @cancel="handleClose"
      centered
    >
    <a-form>
            <a-row :gutter="48">
              <!-- <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:12}">
                <a-form-item class="pre-red" label="是否匿名">
                  <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="postParam.sfnmpy" @change="handleSelectSfnm">
                    <a-select-option v-for="i in TYPE0065" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
               <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:12}">
                <a-form-item class="pre-red" label="评阅人">
                  <a-input :disabled="postParam.sfnmpy==1" placeholder="请输入..." v-model="postParam.pyr" />
                </a-form-item>
              </a-col>
              <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:12}">
                <a-form-item class="pre-red" label="职称">
                  <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="postParam.pyrZcm">
                    <a-select-option v-for="i in TYPE0342" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
               <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:12}">
                <a-form-item class="pre-red" label="单位">
                  <a-input :disabled="postParam.sfnmpy==1" placeholder="请输入..." v-model="postParam.pyrDw" />
                </a-form-item>
              </a-col>
              <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:12}" >
                <a-form-item class="pre-red" label="是否硕导">
                  <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="postParam.sfsd">
                    <a-select-option v-for="i in TYPE0065" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:12}" >
                <a-form-item class="pre-red" label="是否博导">
                  <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="postParam.sfbd">
                    <<a-select-option v-for="i in TYPE0065" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:12}" >
                <a-form-item class="pre-red" label="是否同意答辩">
                  <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="postParam.sftydb">
                    <a-select-option v-for="i in TYPE0368" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col> -->
              <a-col :sm="{span:24}" :lg="{span:24}" :xl="{span:24}" >
                <a-form-item class="pre-red" label="评阅成绩">
                  <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="postParam.pycj">
                    <a-select-option :disabled=" i.code =='03' ? true : false" v-for="i in TYPE0509" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
            </a-row>
          </a-form>
    </a-modal>
</template>

<script>
import { mapState } from 'vuex';

const selectArr = [
  'TYPE0342', //职称
  'TYPE0065', //是否匿名 是否博导 是否硕导 是否达到学位水平
  'TYPE0368', //是否同意答辩
  'TYPE0509', //评阅成绩
]

export default {
  props: {
    editVisible: {
      default: false
    },
    data:{
      default: function () {
        return {
          sfnmpy:'',
          pyr:'',
          pyrZcm:'',
          // sfddxwsp:'',
          pyrDw:'',
          sfsd:'',
          sfbd:'',
          sftydb:'',
          pycj:'',
        }
      }
    },
    confirmLoading: {
      type: Boolean,
      default: false
    }
  },
  watch:{
    data(val){
      this.postParam = val
    }
  },
  data () {
    return {
      postParam: {},
    }
  },
  computed: {
    ...mapState({
      TYPE0342: state => state.app['TYPE0342'], // 职称
      TYPE0065: state => state.app['TYPE0065'], // 是否匿名 是否博导 是否硕导
      TYPE0368: state => state.app['TYPE0368'], // 是否同意答辩
      TYPE0509: state => state.app['TYPE0509'], // 评阅成绩
    })
  },
  created () {
    selectArr.forEach(v => {
      this.$store.dispatch('app/setDictionary', v)
    })
  },
  methods: {
    //选择是否匿名
    handleSelectSfnm(code){
      if (code=="1") {
        this.$set(this.postParam,"pyr","匿名");
        this.$set(this.postParam,"pyrDw","匿名");
      }
    },
    handleSave () {
      delete this.postParam.sfddxwsp
      if (Object.values(this.postParam).includes('')) {
        return this.$message.warn('请输入必填项')
      }
      this.$emit('success',this.postParam)
    },
    handleClose () {
      this.$emit('close')
    }
  }
}
</script>
